﻿using System.Collections.Immutable;
using Turnable.Layouts;

namespace Turnable.Characters;

public record CharacterLocations(ImmutableDictionary<Character, ImmutableList<Location>> Value)
{
    public Location? this[Character character] => Value.ContainsKey(character) ? Value[character].Last() : null;

    public CharacterLocations() : this(ImmutableDictionary<Character, ImmutableList<Location>>.Empty)
    {
    }

    public ImmutableList<Location> Moves(Character character) => Value[character];
    public ImmutableDictionary<Character, Location> Locations() => Value.ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.Last());
    public ImmutableDictionary<Character, Location> Locations(Character characterToExclude) => Locations().Remove(characterToExclude);
};
